Skip to content

feat(transport): introduce stream I/O timeouts - #1518

Draft
rvolosatovs wants to merge 4 commits into
mainfrom
feat/transport-io-timeout
Draft

rvolosatovs wants to merge 4 commits into
mainfrom
feat/transport-io-timeout

Conversation

@rvolosatovs

Copy link
Copy Markdown
Member

closes #1045

@rvolosatovs
rvolosatovs force-pushed the feat/transport-io-timeout branch 2 times, most recently from abaca76 to 7ee06eb Compare October 8, 2026 14:59
@rvolosatovs
rvolosatovs force-pushed the feat/transport-io-timeout branch from 7ee06eb to 216eeea Compare October 23, 2026 13:38
Add an optional timeout to `frame::Incoming` and `frame::Outgoing`,
configured via `with_timeout` and shared by all sub-streams of the
connection. When set, a read that does not make progress within the
timeout fails with `ErrorKind::TimedOut` instead of pending forever,
which lets peers drop invocations whose counterpart stops sending data,
e.g. a client that sends fewer parameter bytes than the function
signature requires and then keeps the stream open. The read deadline is
cleared once it fires, so a read retried after a timeout gets a fresh
window.

`Outgoing` writes are buffered in a channel drained by a detached egress
task, so the write timeout is applied there: egress fails if the
underlying connection does not accept any data within the timeout, the
result is passed to `on_egress` and subsequent writes, flushes and
shutdowns on the stream surface the same error. A peer that stops
reading from the connection therefore causes the connection to be
released, instead of blocking it forever. The timeout is shared with the
egress task through a slot that also holds its waker, so a timeout
configured after the writer has already stalled still arms a deadline.

The QUIC and WebTransport `on_egress` handlers reset the send stream
and return when egress fails, so that the peer observes the failure and
the handler does not wait for a `stopped()`, which quinn never resolves
for a locally reset stream.

Assisted-by: claude:claude-fable-5-1
Assisted-by: claude:claude-opus-5-5
When a transport drains ingress after all `Incoming` handles are
dropped, a peer that never closes its end previously kept the ingress
task and the connection alive forever. If a read timeout is set, fail
ingress with `ErrorKind::TimedOut` once the peer does not close the
stream within the timeout after all handles are dropped, releasing the
connection.

Assisted-by: claude:claude-opus-5-5
Add `invoke::IoTimeout` and `invoke::IoTimeoutOwned` wrappers, which
bound the `Invoke::invoke` call, including the synchronous parameter
write, and apply a read and write timeout to the `Incoming` and
`Outgoing` streams it returns, so that an invocation errors instead of
hanging when the server stops reading or responding mid-invocation.

This is kept separate from `InvokeExt::timeout`, which still only
bounds the `Invoke::invoke` call, since an I/O timeout also bounds the
handler's time to first result byte and applies to async sub-streams,
which may legitimately outlive the invocation and idle for longer.

Assisted-by: claude:claude-fable-5-1
Assisted-by: claude:claude-opus-5-5
Add `serve::IoTimeout` and `serve::IoTimeoutOwned` wrappers, mirroring
the `invoke` ones, which apply a read and write timeout to the
`Incoming` and `Outgoing` streams of every accepted invocation. A client
that sends fewer parameter bytes than the served function expects and
then keeps the connection open previously left the server-side decoder
pending forever (#1045); with a timeout the
invocation now fails with `ErrorKind::TimedOut` and its resources are
released. Likewise, a client that stops reading results no longer
blocks the connection forever.

The timeout does not bound reads a transport does before yielding an
invocation, such as the header read in `frame::Server::accept`.

Closes #1045

Assisted-by: claude:claude-fable-5-1
Assisted-by: claude:claude-opus-5-5
@rvolosatovs
rvolosatovs force-pushed the feat/transport-io-timeout branch from 216eeea to 1aaee8e Compare October 23, 2026 14:25

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant